package com.xlf.common.core.util.file;

/**
 * 文件工具类
 */

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 读取文件相关配置
 */
@Component
@ConfigurationProperties(prefix = "upload-plus")
public class UploadConfig {


    /** 上传路径 ，从根目录开始，最后不带‘/’ eg: D:/text */
    private static String localPath;

    /**
     * 映射到上传根目录的url eg: /profile,配置mvc把这个请求路径映射到上面的上传路径下
     */
    private static String localUrl;


    public static String getLocalUrl(){
        return localUrl;
    }

    public  void setLocalUrl(String localUrl){
        UploadConfig.localUrl = localUrl;
    }

    public static String getLocalPath()
    {
        return localPath;
    }

    public void setLocalPath(String localPath)
    {
        UploadConfig.localPath = localPath;
    }


    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath()
    {
        return getLocalPath() + "/avatar";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath()
    {
        return getLocalPath() + "/download/";
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath()
    {
        return getLocalPath() + "/upload";
    }
}
